<?php
//Khoi tao session
if (!headers_sent()) {session_start();} 
define("ROOT_DIR", dirname(__FILE__) . "/");
define("DBSTYLE", 1); //1 = MySQL , 2 = MSSQL

//database on server linux/windows
//*
define("HOST_DOMAIN_NAME_0","webdesignmarkeing.com");
define("HOST_DOMAIN_NAME", HOST_DOMAIN_NAME_0);
//define("HOST_ACCOUNT_NAME","thietkeg");
define("HOST_ACCOUNT_NAME","thietkeg");

define("ROOT_WS","/");
define("ROOT_FS","/home/".HOST_ACCOUNT_NAME."/public_html/");
//define("ROOT_FS","D:/inetpub/vhosts/".HOST_DOMAIN_NAME_0."/httpdocs/");

define("DATABASE_HOST","localhost");
//define("DATABASE_USER",HOST_ACCOUNT_NAME."_danhba");//Thanh comment
//define("DATABASE_PASSWORD","9x3ul6cx"); //Thanh comment
define("DATABASE_USER","root");
define("DATABASE_PASSWORD","");
define("DATABASE_NAME",HOST_ACCOUNT_NAME."_danhba");
//*/

//Localhost
/*
define("HOST_DOMAIN_NAME","server1:100");
define("ROOT_WS","/hocninh/");
define("ROOT_FS","d:/webphp/hocninh/web/");

define("DATABASE_HOST","localhost");
define("DATABASE_USER","sa");
define("DATABASE_PASSWORD","12");//MSSQL 123456
define("DATABASE_NAME","hocninh");
//*/

//-----------------------------------
//Declare database server login
$DBHOST 	= DATABASE_HOST;
$DBUSER 	= DATABASE_USER;
$DBPASSWORD = DATABASE_PASSWORD;
$DBNAME 	= DATABASE_NAME;

$root_url = "http://".HOST_DOMAIN_NAME."/";
$base_url = "http://".HOST_DOMAIN_NAME.ROOT_WS;
$base_content = "http://".HOST_DOMAIN_NAME.ROOT_WS."content/";
$base_sajax_dir = ROOT_WS."content/";

// defines database server, sid, user, password
$my_dbstyle           = DBSTYLE; 


//================================================================
//giai quyet van do global of
//================================================================
//khoi tao bien
//echo "HTTP_POST_VARS:<br>";
//print_r ($HTTP_POST_VARS);echo "<br>";
foreach ($_POST as $key=>$value){
	//echo "key: $key - value: $value<br>";
	$$key = $value;
}
//echo "HTTP_GET_VARS: <br>";
//print_r ($HTTP_GET_VARS);echo "<br>";
foreach ($_GET as $key=>$value){
	$$key = $value;
}
//echo "HTTP_POST_FILES: <br>";
//print_r ($HTTP_POST_FILES);echo "<br>";
foreach ($_FILES as $var=>$arr){
	//echo "var: $var<br>";
	foreach($arr as $key=>$value){
		//echo "key: $key - value:$value<br>";
		$tmpvar = $var."_".$key;
		$$tmpvar = $value;
		//echo "tmpvar: $tmpvar<br>";
	}
	$$var = $HTTP_POST_FILES[$var]["tmp_name"];
}




//Dinh nghia cac Hang
set_parameters();

//List Pages
$page_size = PAGE_SIZE;
$page_size_news = PAGE_SIZE_NEWS;
$page_size_album = PAGE_SIZE_ALBUM;
$page_size_admin = PAGE_SIZE_ADMIN;
$page_block = PAGE_BLOCK;

//Cau thong bao loi khi dang nhap
$login_err = "Invalid username and password.";

function get_values($s_SQL)
{
	//Connect
    $result;
	if(	DBSTYLE == 1 ){
		$linkID = mysql_connect (DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD); //1-connection
		if( $linkID ) { $selectID = mysql_select_db(DATABASE_NAME, $linkID);} // 2-selection
		//Query
		$resultID = mysql_query ($s_SQL,$linkID) ;//Execute SQL statement
		//echo "s_SQL: $s_SQL<br>====================<br>";
		//Row	
		if ($rowID=mysql_fetch_array($resultID)){
			$result = $rowID[0];
		}
		return $result;
	}else{
		$linkID = mssql_connect (DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD); //1-connection
		if( $linkID ) { $selectID = mssql_select_db(DATABASE_NAME, $linkID);} // 2-selection
		//Query
		$resultID = mssql_query ($s_SQL,$linkID) ;//Execute SQL statement
		//echo "s_SQL: $s_SQL<br>====================<br>";
		//Row	
		if ($rowID=mssql_fetch_array($resultID)){
			$result = $rowID[0];
		}
		return $result;
		
	}
}

//Khoi ta bien- dinh nghia cac Hang so
function set_parameters()
{
	//Connect
	$linkID = mysql_connect (DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD) or die(mysql_error()); //1-connection
	//echo "linkID: $linkID<br>";
 	if( $linkID ) { $selectID = mysql_select_db(DATABASE_NAME, $linkID) or die(mysql_error());} // 2-selection
	//Query
	$s_SQL = "select configuration_key as cfgKey, configuration_value as cfgValue from configuration";
	$resultID = mysql_query ($s_SQL,$linkID) or die(mysql_error());  ;//Execute SQL statement
	//echo "resultID: $resultID<br>";
	//Row
	while ($configuration = mysql_fetch_array($resultID)) {
    	define($configuration['cfgKey'], $configuration['cfgValue']);
  	}		
}

?>